/* 
 * File:   Shoot.cpp
 * Author: brunoslr
 * 
 * Created on 16 de Setembro de 2009, 10:18
 */
#include "Shoot.h"

Shoot::Shoot() {
    status = false;

}

Shoot::Shoot(double x, double y, double ShooterHeight, int direction) {
    status = true;
    positionx = x;
    positiony = y;
    drawShoot(ShooterHeight, direction);
    radius = 0.015;
       
}

Shoot::Shoot(const Shoot& orig) {
}

Shoot::~Shoot() {
}

int Shoot::drawShoot(double ShooterHeight, int direction) {
    if(status==true){
        glBegin(GL_QUADS);
        glColor3f(1.0,0.80,0.0);
        glVertex2f(positionx - 0.01, positiony - direction*ShooterHeight);
        glVertex2f(positionx - 0.01, positiony - direction*ShooterHeight*0.80);
        glVertex2f(positionx + 0.01, positiony - direction*ShooterHeight*0.80);
        glVertex2f(positionx + 0.01, positiony - direction*ShooterHeight);
        glEnd();
        }

    return 0;
}

int Shoot::move(double speed, int direction){

    if(status==true){
         positiony += speed*direction;

         if(positiony >=  HEIGHT || positiony < 0) status = false;

    } return 0;
}

int Shoot::move(int direction){

    if(status==true){
         positiony += 0.11*direction;

         if(positiony >=  HEIGHT || positiony < 0) status = false;

    } return 0;
}


int Shoot::collisionTest(double raio, double x, double y){

    double distancia = sqrt(pow(x-positionx,2) + pow(y -positiony,2));
  
    if(distancia < (raio+this->radius)){
        return 1;
    }
    return 0;

}
